<?php
class Formatter extends CFormatter
{
	public function dateHumanToNormal($date)
	{
		$dateArr = date_parse_from_format("d.m.Y", $date);
		return "{$dateArr['year']}-{$dateArr['month']}-{$dateArr['day']}";
	}

	public function dateHumanByTime($time)
	{
		return $this->dateNormalToHuman(date('Y-m-d', $time));
	}

	public function dateNormalToHuman($date)
	{
		$dateArr = date_parse_from_format("Y.m.d", $date);
		$day = $this->addZeroToNumber($dateArr['day']);
		$month = $this->addZeroToNumber($dateArr['month']);
		$year = $dateArr['year'];
		return "{$day}.{$month}.{$year}";
	}

	protected function addZeroToNumber($number)
	{
		if ($number <= 9) {
			$number = '0' . $number;
		}
		return $number;
	}
}